import GameUtil from "../../Fantasy/Util/GameUtil";
import SoundUtil from "../../Fantasy/Util/SoundUtil";


const {ccclass, property} = cc._decorator;

@ccclass
export default class ExitDialog extends cc.Component {

    isExitGame;
    setIsExitGame(bool){
        this.isExitGame = bool
    }
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}
    btnCallback(target,data){
        SoundUtil.playEffect("music/click");
        if(data == "sure"){
            if(this.isExitGame == true){
                Log("退出游戏");
                cc.game.end();
            }else{
                // GameUtil.gotoScene("MainScene");
                if(GameUtil.sceneName == "GameScene"){
                    GameUtil.gotoScene("MainScene",()=>{
                        cc.find("Canvas").getComponent("MainScene").btnCallback(null,"Rush");
                    },true);
                }else{
                    GameUtil.gotoScene("MainScene",()=>{
                        cc.find("Canvas").getComponent("MainScene").btnCallback(null,"PK");
                    },true);
                }
            }
        }else if(data == "cancel"){
            this.node.destroy();
        }
    }
    start () {

    }

    // update (dt) {}
}
